package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.CompanyAptitude;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241022
 */
@Mapper
public interface CompanyAptitudeMapstruct {

    CompanyAptitudeMapstruct INSTANCE = Mappers.getMapper(CompanyAptitudeMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    CompanyAptitudeVo toCompanyAptitudeVo(CompanyAptitude source);

    default List<CompanyAptitudeVo> toCompanyAptitudeVoList(List<CompanyAptitude> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toCompanyAptitudeVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class CompanyAptitudeVo extends CompanyAptitude {

        @ApiModelProperty(value = "资质附件")
        private List<AppFileMapstruct.FileVo> files;

    }

    @ApiModel(value = "行级权限对象")
    @Data
    class CompanyAptitudeRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public CompanyAptitudeRowAuthVo(CompanyAptitude entity) {
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }

    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String companyAptitudeId;

        @NotBlank(message = "公司ID为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 36, message = "主键长度不能超过36", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "公司ID")
        private String companyId;

        @NotBlank(message = "资质名称不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "资质名称")
        private String companyAptitudeName;

        @NotNull(message = "等级不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "等级")
        private String lv;

        @ApiModelProperty(value = "有效结束时间")
        private LocalDate validEndDate;

        @NotNull(message = "资质文件不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "资质文件")
        private AppFileMapstruct.FileVo fileVo;

        @ApiModelProperty(value = "审核id")
        private String checkId;


    }

    //-------------------------------- springboot验证标识 --------------------------------

}
